1

00:00:00,213  -->  00:00:06,558
In the previous video, We already create a
script to looping in the list ip address.

2

00:00:07,136  -->  00:00:15,000
So here we have a list that save the ip address
of all router, and then we do looping to this list.

3

00:00:15,786  -->  00:00:25,703
But if you remember, the ip address of loopback
is same on all router, which is 10.5.1.1.

4

00:00:26,675  -->  00:00:33,215
Now, we are going to modify this script, so
the last number in the loopback ip address

5

00:00:33,215  -->  00:00:37,766
will based on the last number in the router
ip address.

6

00:00:38,816  -->  00:00:45,596
Here we have the ip address list of all router,
so we will use the last number,

7

00:00:45,727  -->  00:00:50,422
which is 1 2 3 4 and 5.

8

00:00:51,105  -->  00:00:55,807
And then this last number will used in the
loopback ip address.

9

00:00:56,635  -->  00:00:58,184
How we can do that?

10

00:00:58,499  -->  00:01:01,740
Let’s try it in the python interpreter first.

11

00:01:02,384  -->  00:01:10,454
Copy this, go to terminal, and then go to
python interpreter.

12

00:01:11,124  -->  00:01:17,029
Let’s clear this using ctrl + l. and then
paste the script.

13

00:01:19,025  -->  00:01:20,890
Let’s print the list_ip,

14

00:01:23,333  -->  00:01:25,799
Okay this is the list.

15

00:01:26,653  -->  00:01:35,927
Let’s try to looping here, for ip in list_ip,
and then print the ip,

16

00:01:37,910  -->  00:01:48,293
Here we get the ip address of all router,
10.1, 10.2, 10.3, 10.4, and 10.5.

17

00:01:49,134  -->  00:01:57,216
Here we can see that the data type of each
ip address is tring, here we have a quote,

18

00:01:57,492  -->  00:01:59,286
this is means string.

19

00:02:00,000  -->  00:02:08,648
Let’s check it, up arrow until we see the
looping again, and then here let’s print

20

00:02:08,648  -->  00:02:10,688
the type of ip.

21

00:02:13,157  -->  00:02:16,126
Here we can see that the type is string.

22

00:02:17,058  -->  00:02:25,168
In the string, we have method split, this
method will split the string become a list.

23

00:02:25,640  -->  00:02:27,000
Let’s try it,

24

00:02:27,946  -->  00:02:40,285
For ip in list_ip, and then let’s try to
split this ip, ip_split, this is just a variable,

25

00:02:40,915  -->  00:02:50,043
And then ip.split(“.”), this is means
that we split the ip based on dot .

26

00:02:51,000  -->  00:03:01,674
So the result will be a list, 10 10 10 and
then 1, let’s print the ip_split here.

27

00:03:06,153  -->  00:03:07,828
Enter 2 times,

28

00:03:08,340  -->  00:03:18,000
Okay this is router 1, this is router 2, this
is router 3, this is router 4, and this is router 5.

29

00:03:19,034  -->  00:03:24,085
Okay so now we can access the last number
using indexing.

30

00:03:24,755  -->  00:03:37,745
In python, the index is started by 0, so here
0 1 2 3, so the index of last number is 3,

31

00:03:38,099  -->  00:03:42,000
or we also can use reverse indexing

32

00:03:42,702  -->  00:03:51,578
Reverse indexing is start from the last item,
the index of last item is -1.

33

00:03:52,510  -->  00:03:55,758
Okay now let’s try to print the last number.

34

00:03:56,309  -->  00:04:12,214
For ip in list_ip, ip_split ip.split dot,
and then let’s print the ip_split index 3,

35

00:04:14,501  -->  00:04:21,282
Or you can also using reverse indexing, so
the index will be -1.

36

00:04:22,162  -->  00:04:23,620
Enter 2 times,

37

00:04:24,145  -->  00:04:29,877
Okay here we get 1 2 3 4 and 5,

38

00:04:30,941  -->  00:04:37,977
We will use this number as the ip address
of loopback interface, so the ip address of

39

00:04:37,977  -->  00:04:41,933
loopback interface for each router will be
different.

40

00:04:42,839  -->  00:04:50,046
Now let’s back to sublime, here let’s
take the last number of the ip address like

41

00:04:50,046  -->  00:04:53,318
we already do in the python interpreter.

42

00:04:54,250  -->  00:04:59,592
Router_id, this is just a variable, you can
use anything.

43

00:05:00,000  -->  00:05:07,283
And then ip.split, dot, so we split the ip
based on dot.

44

00:05:07,913  -->  00:05:14,575
And then here let’s access the index -1,
which is the last item.

45

00:05:15,784  -->  00:05:18,751
Next, let’s configure for loopback5,

46

00:05:20,616  -->  00:05:30,320
The ip address is 10.6 and then here will
be based on router_id, so we use f string,

47

00:05:30,503  -->  00:05:33,225
And then here router_id.

48

00:05:35,680  -->  00:05:45,613
Okay save, back to therminal, exit from interpreter,

49

00:05:46,624  -->  00:05:54,545
And then here let’s execute
the script, python paramiiko_looping_list.py,

50

00:05:56,817  -->  00:05:58,413
enter enter here,

51

00:06:04,179  -->  00:06:11,346
Okay here we success on router 1, the ip address
is 10.6.1.1,

52

00:06:11,937  -->  00:06:17,756
Router 2 also success, the ip address is 10.6.1.2,

53

00:06:18,347  -->  00:06:21,907
Router 3, also success, the ip address is 10.6.1.3,
this is 3.

54

00:06:22,734  -->  00:06:26,332
Router 4 also success, this is 4.

55

00:06:26,713  -->  00:06:31,357
And last, router 5 also success, this is 5.

56

00:06:32,172  -->  00:06:35,111
Okay I think enough for this video

57

00:06:35,242  -->  00:06:38,808
Thankyou for watching and see you on the next video.
